package com.woniu.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu.domain.CourseManagementDTO;
import com.woniu.domain.MapUserLeave;
import com.woniu.service.MapUserLeaveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: ljy  <br/>
 * Date: 2021/6/9:11:05  <br/>
 * Description:学习进度控制器
 */
@RestController
@RequestMapping("/mapUserLeave/")
public class MapUserLeaveController {
    @Autowired(required = false)
    MapUserLeaveService mapUserLeaveService;

    /*
     * Description :根据地图id查询对应学习情况  <br/>
     * ChangeLog : 1. 创建 (2021/6/9 11:08 [刘家元]);
     ** @param page   起始页码 pageSize 每页条数   mapId 地图id
     * *  @return  PageInfo<MapUserLeave> 分页后的数据集合
    */
    @RequestMapping("queryList")
    public PageInfo<MapUserLeave> getMapUserLeaveByMapId(Integer page,Integer pageSize,Integer mapId){
        PageHelper.startPage(page,pageSize);
        List<MapUserLeave> mapUserLeaveList = mapUserLeaveService.getMapUserLeaveByMapId(mapId);
        PageInfo<MapUserLeave> pageInfo = new PageInfo<>(mapUserLeaveList);
        return pageInfo;
    }


    /*
     * Description :条件查询对应学习情况  <br/>
     * ChangeLog : 1. 创建 (2021/6/9 11:08 [刘家元]);
     ** @param courseManagementDTO 封装的起始页   每页数量   查询条件
     * *  @return  PageInfo<MapUserLeave> 分页后的数据集合
     */
    @RequestMapping("conditionQuery")
    public PageInfo<MapUserLeave> conditionQueryMapUserLeaveByMapId(@RequestBody CourseManagementDTO<MapUserLeave> courseManagementDTO){
        PageHelper.startPage(courseManagementDTO.getPage(),courseManagementDTO.getPageSize());
        List<MapUserLeave> mapUserLeaveList = mapUserLeaveService.conditionQueryMapUserLeaveByMapId((MapUserLeave)courseManagementDTO.getObj());
        PageInfo<MapUserLeave> pageInfo = new PageInfo<>(mapUserLeaveList);
        return pageInfo;
    }
}
